package Terminal.UI;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JPanel;

public class PanelButton extends PanelComponent {

	private JButton button;

	public PanelButton(PanelComponent parent){
		super(parent);
		pannellocomponente = new JPanel(null);
		button= new JButton();
		
	}
	public PanelButton(PanelComponent parent, JButton button)
	{
		super(parent);
		pannellocomponente = new JPanel(null);
		this.button= button;
		this.button.setFont(new Font(this.button.getFont().getName(), Font.PLAIN, 16));
	}
	
	@Override
	public JPanel createComponents() {
		//button = new JButton();
		/*button.setLocation(0,0);
		button.setSize(new Dimension(100, 25));
		button.setPreferredSize(new Dimension(100, 25));
		button.setMinimumSize(new Dimension(100, 25));*/
		
		pannellocomponente.add(button);
		setSize(button.getPreferredSize());
	//	System.out.print("\n button"+button.getPreferredSize()+" "+button.getSize());
		pannellocomponente.setBackground(Color.white);
		return pannellocomponente;
	}

	public JButton getButton(){
		return button;
	}
	
	/*public void setButton(JButton but){
		button=but;

	
		
		setSize(button.getPreferredSize());
	}*/
	
	public void setSize(int width, int height){
		Dimension d = new Dimension(width, height);
		super.setSize(d);
		button.setSize(d);
		button.setPreferredSize(d);
		button.setMinimumSize(d);	
	}
	
	public void setSize(Dimension d){
		super.setSize(d);
		button.setSize(d);
		button.setPreferredSize(d);
		button.setMinimumSize(d);	
		
	}
	@Override
	public void updateSize() {	}

}
